package com.pig.live.common.utils;

import com.pig.live.common.core.domain.ResultBean;
import com.pig.live.common.enums.ResultCodeEnum;

/**
 * @author gaojx
 * @since 2020/8/16
 */
public class ResultUtils {

    public static <T> ResultBean<T> success(T data){
        ResultBean<T> resultBean = new ResultBean<>();
        return resultBean.setSuccess(true)
                .setCode(ResultCodeEnum.SUCCESS.getCode())
                .setMessage(ResultCodeEnum.SUCCESS.getMessage())
                .setData(data);

    }

    public static ResultBean<Void> error(String code, String message){
        ResultBean<Void> resultBean = new ResultBean<>();
        return resultBean.setCode(code).setMessage(message);
    }

    public static ResultBean<Void> error(ResultCodeEnum status){
        return new ResultBean<>(status);
    }
}
